<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>网页计算器</title>
</head>
<body>

    <p>
        整数一：<input type="text" id="one" autofocus>
    </p>
    <p>
        整数二：<input type="text" id="two">
    </p>
    <p>
        <button onclick="wn('a')">相加</button>
        <button onclick="wn('b')">相减</button>
        <button onclick="wn('c')">相乘</button>
        <button onclick="wn('d')">相除</button>
    </p>
    <p>
        结果：<input type="text" id="zs" contenteditable="false">
    </p>


    <script>

        function wn(i){
            var yi = document.querySelector("#one").value;
            var er = document.querySelector("#two").value;
            yi = Number(yi);
            er = Number(er);
            switch (i){
                case "a":
                    document.querySelector("#zs").value =  yi + er ;
                    break;
                case "b":
                    document.querySelector("#zs").value = yi - er;
                    break;
                case "c":
                    document.querySelector("#zs").value = yi * er;
                    break;
                case 'd':
                    document.querySelector("#zs").value = yi / er;
                    break;
            }
        }

    </script>
</body>
</html>